package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseBaseApi;
import com.xuecheng.api.content.model.qo.QueryCourseBaseModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 课程基本信息 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CourseBaseController implements CourseBaseApi {

    @Autowired
    private CourseBaseService  courseBaseService;

    /**
     * SpringMVC对于参数的接收类型：
     * 默认：QueryString（@RequestParam(xxxx))
     * RequestBody:Body(@RequestBody--将请求体中的json数据转为实体类对象数据）
     *
     * 前提：封装类型中的属性名称必须要和前端传入的key值保持一致
     */
    @PostMapping("course/list")
    public PageVO queryCourseList(PageRequestParams params, QueryCourseBaseModel model) {

        //获取令牌并解析拿到公司的id值
        Long companyId = SecurityUtil.getCompanyId();
        PageVO pageVO = courseBaseService.queryCourseBaseList(params, model, companyId);
        return pageVO;
    }



}
